package cn.guoshiweixue.utils.controller;

import cn.guoshiweixue.utils.model.Product;
import io.swagger.v3.oas.annotations.Operation;
import io.swagger.v3.oas.annotations.Parameter;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Value;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import java.math.BigDecimal;

/**
 * @author guoshiweixue
 */
@RestController
@RequestMapping("/utils")
@Slf4j
public class HelloController {

    @Value("${hello.message:Hello from Weixue Utils!}")
    private String helloMessage;

    @Operation(summary = "Say hello", description = "Returns a friendly greeting")
    @GetMapping("/hello")
    public String sayHello() {
        return helloMessage;
    }

    @Operation(summary = "Get product details", description = "Returns product details based on ID")
    @GetMapping("/products/{id}")
    public Product getProduct(@Parameter(description = "产品编号") @PathVariable Long id) {
        // Dummy data for demonstration
        System.out.println("请求查询的编号是：" + id);
        Product product = new Product();
        product.setId(id);
        product.setName("WeiXue Utils");
        product.setPrice(new BigDecimal(99.99));
        return product;
    }
}
